package com.leoman.spinningmachine.tab1;

import android.os.Bundle;
import android.widget.RadioGroup;

import com.leoman.helper.util.AppManager;
import com.leoman.helper.util.FragmentController;
import com.leoman.spinningmachine.R;
import com.leoman.spinningmachine.base.BaseActivity;

import butterknife.BindView;

/**
 * 门禁系统
 */
public class EntranceGuardActivity extends BaseActivity {

    private String[] fragmentTags = {"tab1", "tab2", "tab3"};
    private Class[] cla = {BluetoothFragment.class, SweepFragment2.class, OcrFragment.class};
    private FragmentController mFragmentController;
    @BindView(R.id.rg)
    RadioGroup radioGroup;

    @Override
    protected int getContentViewLayoutID() {
        return R.layout.ac_entrance_guard;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        AppManager.getInstance().addActivity(this);
        initTitle("门禁系统");
//        requestPermission();
    }

    @Override
    protected void initData() {
        mFragmentController = new FragmentController(getSupportFragmentManager(), R.id.realtabcontent, fragmentTags, this);

        setFragment(1);
        setFragment(0);
        radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                switch (checkedId) {
                    case R.id.rb_tab1:
                        setFragment(0);
                        break;
                    case R.id.rb_tab2:
                        setFragment(1);
                        break;
                    case R.id.rb_tab3:
                        setFragment(2);
                        break;
                }
            }
        });
    }

    private void setFragment(int tag) {
        mFragmentController.add(cla[1], fragmentTags[1], null);
    }


//    private void requestPermission() {
//        boolean mResultStr = SharedPreferencesUtils.getInstance().getBoolean(Constant.ISFRISTPERMISSION);
//        if (Build.VERSION.SDK_INT >= 23 && !mResultStr) {
//            String[] mPermissionList = new String[]{  Manifest.permission.CAMERA,Manifest.permission.BLUETOOTH,Manifest.permission.BLUETOOTH_ADMIN,
//                     Manifest.permission.WRITE_EXTERNAL_STORAGE,
//                    Manifest.permission.ACCESS_NETWORK_STATE, Manifest.permission.ACCESS_WIFI_STATE, Manifest.permission.CHANGE_WIFI_STATE, Manifest.permission.WAKE_LOCK,
//                    Manifest.permission.WRITE_SETTINGS,  Manifest.permission.SYSTEM_ALERT_WINDOW, Manifest.permission.GET_ACCOUNTS,
//                    Manifest.permission.DISABLE_KEYGUARD,
//                    Manifest.permission.READ_EXTERNAL_STORAGE,
//            };
//            ActivityCompat.requestPermissions(this, mPermissionList, 100);
//            SharedPreferencesUtils.getInstance().putBoolean(Constant.ISFRISTPERMISSION, true);
//        }
//    }

}
